package top.goldenyear.porpoise.system.auth.controller.admin;

import cn.dev33.satoken.annotation.SaIgnore;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.*;
import org.noear.solon.validation.annotation.Validated;
import top.goldenyear.porpoise.common.core.model.Ret;
import top.goldenyear.porpoise.system.auth.dto.LoginReq;
import top.goldenyear.porpoise.system.auth.dto.RefreshTokenReq;
import top.goldenyear.porpoise.system.auth.service.LoginService;

/**
 * @author airhead
 */
@Component(tag = "adminApi")
@Mapping("/auth")
@Slf4j
public class LoginAdminController {
  @Inject private LoginService service;

  @Post
  @Mapping("login")
  @SaIgnore
  public Ret login(@Validated @Body LoginReq loginReq) {
    return service.login(loginReq);
  }

  @Get
  @Mapping("getUserInfo")
  public Ret getUserInfo() {
    return service.getUserInfo();
  }

  @Post
  @Mapping("refreshToken")
  @SaIgnore
  public Ret refreshToken(@Validated @Body RefreshTokenReq refreshTokenReq) {
    return service.refreshToken(refreshTokenReq);
  }
}
